from tkinter import *

from config import *
from sql import sqlseverDB
from mini_tools.cjjtool import *
from mini_tools.myexcel import *
from mini_tools.mytools import *
from my_frame.homegnclass import HomeFrame
from my_frame.updown import DataFra
from my_frame.admin import Data2Fra
from my_frame.desfanyi import DataFra3
from my_frame.minifuc import MiniFra
from my_frame.admin2 import Data4Fra
from my_frame.allegro import DataFra9
from my_frame.amazon import AmazonFra
from my_frame.btfanyi import FYFra


class GnnFrame(Frame):
    def __init__(self,master=None):
        Frame.__init__(self,master)
        self.ms = sqlseverDB('{SQL Server}', SQL_SERVER, 'SuMaiTongPol', SQL_USER, SQL_PWD)
        self.rowCount=IntVar()
        self.createWidgets()

    def createWidgets(self):

                
        self.rbtnFra=Frame(self,width=800)
        self.rbtnFra.pack(pady=5)
        self.v = IntVar()
        self.v.set(1)
        pidfra=HomeFrame(self)
        datafra=DataFra(self)
        data2fra=Data2Fra(self)
        data3fra=DataFra3(self)
        minifra=MiniFra(self)
        data4fra=Data4Fra(self)
        data8fra=Data8Fra(self)
        data9fra=DataFra9(self)
        amazonfra=AmazonFra(self)
        fyfra=FYFra(self)
        self.lfras=[pidfra,datafra,data2fra,data4fra,data3fra,minifra,data8fra,data9fra,amazonfra,fyfra]

    def changesr(self):

        j=1
        for fra in self.lfras:
            if j==self.v.get():
                fra.pack(fill=X)
            else:
                fra.pack_forget()
            j+=1

    
    def cgpb(self,utype):
        rbtnFra=self.rbtnFra
        if utype==1 or utype==2:
            Radiobutton(rbtnFra, text="采集", variable=self.v, value=1,command=self.changesr).grid(row=0,column=1,padx=3)
            Radiobutton(rbtnFra, text="数据管理", variable=self.v, value=2,command=self.changesr).grid(row=0,column=2,padx=3)
            Radiobutton(rbtnFra, text="ADMIN", variable=self.v, value=3,command=self.changesr).grid(row=0,column=4,padx=3)
            Radiobutton(rbtnFra, text="ADMIN2", variable=self.v, value=4,command=self.changesr).grid(row=0,column=5,padx=3)
            Radiobutton(rbtnFra, text="ADMIN3", variable=self.v, value=7,command=self.changesr).grid(row=0,column=6,padx=3)
            Radiobutton(rbtnFra, text="沂敏", variable=self.v, value=5,command=self.changesr).grid(row=0,column=7,padx=3)
            Radiobutton(rbtnFra, text="Allegro", variable=self.v, value=8,command=self.changesr).grid(row=1,column=1,padx=3)
            Radiobutton(rbtnFra, text="小工具", variable=self.v, value=6,command=self.changesr).grid(row=0,column=3,padx=3)
            Radiobutton(rbtnFra, text="AMAZON", variable=self.v, value=9,command=self.changesr).grid(row=1,column=2,padx=3)
        
        elif utype==3:
            self.v.set(8)
            Radiobutton(rbtnFra, text="Allegro", variable=self.v, value=8,command=self.changesr).grid(row=0,column=0,padx=3)
            Radiobutton(rbtnFra, text="采集", variable=self.v, value=1,command=self.changesr).grid(row=0,column=1,padx=3)
            Radiobutton(rbtnFra, text="ADMIN", variable=self.v, value=3,command=self.changesr).grid(row=0,column=4,padx=3)
            Radiobutton(rbtnFra, text="数据管理", variable=self.v, value=2,command=self.changesr).grid(row=0,column=5,padx=3)
            Radiobutton(rbtnFra, text="小工具", variable=self.v, value=6,command=self.changesr).grid(row=0,column=3,padx=3)
            Radiobutton(rbtnFra, text="AMAZON", variable=self.v, value=9,command=self.changesr).grid(row=0,column=6,padx=3)

        elif utype==4:
            self.v.set(6)
            Radiobutton(rbtnFra, text="小工具", variable=self.v, value=6,command=self.changesr).grid(row=0,column=3,padx=3)
        
        elif utype==5:
            self.v.set(9)
            Radiobutton(rbtnFra, text="AMAZON", variable=self.v, value=9,command=self.changesr).grid(row=0,column=1,padx=3)
            Radiobutton(rbtnFra, text="虾皮翻译", variable=self.v, value=10,command=self.changesr).grid(row=0,column=2,padx=3)
            Radiobutton(rbtnFra, text="小工具", variable=self.v, value=6,command=self.changesr).grid(row=0,column=3,padx=3)


        self.changesr()



    


         
# import tkinter
# list_win=tkinter.Tk()
# list_win.wm_geometry("800x650")
# list_win.title('allgero')
# DataFra9(list_win).pack(fill=X,padx=3,pady=3)
# list_win.mainloop()